var satTemplate = null;

function drawSat()
{
	try
	{
		var canvas = document.getElementById('gps-vsdisp');
		if (canvas.getContext)
		{
			var r = 50,ctx;
			
			ctx = canvas.getContext('2d');
			
			ctx.clearRect ( 0 , 0 , 1000 , 1000 );
			
			ctx.beginPath();
			ctx.fillStyle = "#333";
			ctx.arc(500, 500, 500, 0, 2*Math.PI, false);
			ctx.fill();
			
			ctx.beginPath();
			ctx.strokeStyle = "#CCC";
			ctx.arc(500, 500, 250, 0, 2*Math.PI, false);
			ctx.stroke();
			
			ctx.beginPath();
			ctx.moveTo(500,0);
			ctx.lineTo(500,1000);
			ctx.moveTo(0,500);
			ctx.lineTo(1000,500);
			ctx.stroke();
			
			ctx.textAlign = "center";
		    ctx.textBaseline = "center";
	    	ctx.font = "50pt Calibri";
			
			for (var i=0; i<gps_vsat_count; i++)
			{
				ctx.save();
				var range = 500*Math.sin(gps_vsat[i]['elev']*Math.PI/180);
				ctx.translate(500 + (range*Math.cos((gps_vsat[i]['azi']-90)*Math.PI/180)),
							  500 + (range*Math.sin((gps_vsat[i]['azi']-90)*Math.PI/180)));
				ctx.beginPath();
				ctx.arc(0, 0, r, 0, 2*Math.PI, false);
				ctx.fillStyle = "#000";
				ctx.fill();
				
				ctx.beginPath();
				ctx.arc(0, 0, r, 0, 2*Math.PI * gps_vsat[i]['snr']/100, false);
				ctx.lineTo(0,0);
				ctx.closePath();
				ctx.fillStyle = "#00F";
				ctx.fill();
				
				ctx.fillStyle = "#FFF"
				ctx.fillText(gps_vsat[i]['prn'],0,0);
				
				ctx.restore();
			}
		}
	}
	catch (e){alert(e);}
}